using System;
using System.Linq;
using EP.Entities;

namespace Api
{
    public static class DbInitializer
    {
        public static void Initialize(GeneralDbContext context)
        {
            context.Database.EnsureCreated();
            if (context.TodoItems.Any())
            {
                return;
            }
            var todoItems = new TodoItem[10];
            for (int i = 0; i < 10; i++)
            {
                todoItems[i] = new TodoItem { Name = "TEST" + i, IsComplete = i % 2 == 0 };
            }
            context.AddRange(todoItems);
            context.SaveChanges();
        }
    }
}